package praktikumid.w09.p2.interface_example;

import java.util.ArrayList;
import java.util.List;

/**
 * Example of interface usage.
 * @author Ago
 *
 */
public class InterfaceExample {

	/**
	 * Main.
	 * @param args Arguments.
	 */
	public static void main(String[] args) {
		// new plane (a concrete type of vehicle)
		Plane p = new Plane();
		// a list of vehicles, can hold different type of vehicles
		List<Vehicle> vehicles = new ArrayList<Vehicle>();
		// add plane
		vehicles.add(p);
		// add a new car
		vehicles.add(new Car());
		// add a new helicopter
		vehicles.add(new Helicopter());
		
		// plane follows a new car
		p.follow(new Car());

		// let's loop over the list
		for (Vehicle v : vehicles) {
			if (v instanceof Car) {
				// here we only have Car objects
			}
			
			if (v instanceof IDrivableOnSurface) {
				// here we only have objects
				// which can drive on surface
			}
		}
	}

}
